[Adobe Air] Can I catch a mouseUp event of an mx:Window that did not fire hte mouseDown?

Posted by Irene on Stack Overflow See other posts from Stack Overflow or by Irene
Published on 2010-05-07T12:55:19Z Indexed on 2010/05/07 12:58 UTC
Read the original article Hit count: 248

Hi,

In an AIR application, I have one mx:TileList with several images. What I need to do is let the user drag and drop one of the images on the desktop, giving a feeling of a desktop widget. Firstly I tried to implement this using dragStart etc, but in the end I think it is easier to handle mouseDown and mouseUp on the TileList.

In general the whole setup works as desired. When a mouseDown is detected on the TileList, I create a transparent mx:Window containing the corresponding image, and call the startMove() on the Window to simulate a dragging behavior. If I release the mouse, the Window stops moving as desired.

My problem is that now I want some visual feedback during dragging. It works while the Window is moving, however I can't find a way to stop it when the user releases the mouse. The mouseUp is not fired from the TileList, nor from the s:WindowedApplication. I also tried to add a listener to the Window itself, but still with no luck.

Some code:

private function onMouseDown(e:MouseEvent):void {
  trace ("down " + e.target);
  if (e.target is TileListItemRenderer) {
    // first create a dragWindow
    dragWindow.startGlow(); // then show some visual feedback
    dragWindow.moveWindow(e); // and start dragging 
  }
}

private function onMouseUp(e:MouseEvent):void {
  trace("up " + e.target);
  dragWindow.stopGlow(); // <--------- Not called!
} 

<mx:TileList id="photoTileList" mouseDown="onMouseDown(event)" mouseUp="onMouseUp(event)">

© Stack Overflow or respective owner

Related posts about adobe-air

Related posts about adobe-flex